package main

import (
	"fmt"
	"sunibas.cn/DIP/Utils"
)

func main()  {
	//createPGM()
	var pmg = Utils.PgmFile{
		FileName: "E:\\研究生作业\\DIP\\Chapter2_1.pgm",
	}
	pmg.OpenFile()
	for _,b := range pmg.Img {
		fmt.Print(b)
		fmt.Print(",")
	}
}

func createPGM()  {
	width := 256
	height := 256
	img := make([]byte,256 * 256)

	colors := []byte {75,135,195,255}
	maps := []int {
		0,1,2,3,
		3,0,1,2,
		2,3,0,1,
		1,2,3,0,
	}
	for i := 0;i < width;i++ {
		for j := 0;j < height;j++ {
			locX := i / 64
			locY := j / 64
			img[i + j * 256] = colors[maps[locX + locY * 4]]
		}
	}


	pgm := Utils.PgmFile{
		Type: Utils.PgmType_P5,
		Info: "Create by IBAS",
		Width: width,
		Height: height,
		PixelLength: 255,
		Img: img,
	}
	pgm.Save("E:\\研究生作业\\DIP\\test.pgm")
}

